#include "MountDisplay.h"

//#include "moc_MountDisplay.cxx"
#include "ui_MountDisplay.h"
#include <indicom.h>

LCDsexa::LCDsexa(QWidget* parent): QLCDNumber(parent)
{
  isSexa = false;
}

LCDsexa::LCDsexa(uint numDigits, QWidget* parent): QLCDNumber(numDigits, parent)
{
 isSexa = false;
}


void LCDsexa::setMode(QLCDNumber::Mode m)
{
  isSexa=false;
  QLCDNumber::setMode(m);
}

void LCDsexa::setSexaMode(int width, int fbase)
{
  isSexa = true;
  w = width;
  fracbase=fbase;
}

void LCDsexa::display(double num)
{
  if (isSexa) {
    char repr[13];
    fs_sexa(repr, num, w, fracbase); 
    QLCDNumber::display(QString(repr));
  }
  else
    QLCDNumber::display(num);
}



MountDisplay::MountDisplay()
:QObject()
{
  ui = new Ui::MountDisplay();
}

void MountDisplay::setupUi(QWidget* parent)
{
  ui->setupUi(parent);
  ui->lcdNumberRA->setSexaMode(2, 3600);
  ui->lcdNumberDEC->setSexaMode(2, 3600);
  ui->lcdNumberAlt->setSexaMode(2, 3600);
  ui->lcdNumberAz->setSexaMode(3, 3600);
  ui->lcdNumberLST->setSexaMode(2, 3600);
}

void MountDisplay::changeEquatorialCoords(double ra, double dec)
{
  setRA(ra);
  setDEC(dec);
}

void MountDisplay::changeHorizontalCoords(double alt, double az)
{
  setAlt(alt);
  setAz(az);
}

void MountDisplay::changeLST(double lst)
{
  setLST(lst);
}


void MountDisplay::setRA(double n)
{
  ui->lcdNumberRA->display(n); 
}

void MountDisplay::setDEC(double n)
{
  ui->lcdNumberDEC->display(n); 
}

void MountDisplay::setAlt(double n)
{
  ui->lcdNumberAlt->display(n); 
}

void MountDisplay::setAz(double n)
{
  ui->lcdNumberAz->display(n); 
}


void MountDisplay::setLST(double lst)
{
  //char lststr[9];
  ui->lcdNumberLST->display(lst);
  //fs_sexa(lststr, lst, 2, 3600);
  //sclst->setText(QString("LST: ")+QString(lst));
  //ui->graphicsView->repaint();
}


